#ifndef _DYNAMICARRAY_H_
#define _DYNAMICARRAY_H_
#include <stdbool.h>
#define ElementType void*
#define INITDARRY(a)    DArray a;InitDynamicArray(&a);

typedef struct DynamicArray DArray;
#ifndef __DYNAMICARRAY_H_
#define __DYNAMICARRAY_H_

#define ElementType void*
#include <cstdbool>

typedef void (*ClearCallback)(void*);

class DynamicArray
{
public:
    DynamicArray(); 
    DynamicArray(const DynamicArray& array);
    ~DynamicArray();
    void InsertTail(ElementType element);
    bool RemoveByIndex(int index,void (*ClearPtr)(ElementType));
    bool RemoveByElement(ElementType element, bool (*funcPtr)(ElementType, ElementType),void (*ClearPtr)(ElementType));
    bool RemoveFirstElement(ElementType element, bool (*funcPtr)(ElementType, ElementType), void (*ClearPtr)(ElementType));
    void FindElement(ElementType element, bool (*funcPtr)(ElementType, ElementType));
    void Sort(bool (*funcPtr)(ElementType, ElementType));
    void show();
    void setClearPtr(ClearCallback callback) 
    {
        ClearPtr = callback;
    }
private:
    ElementType* dp;
    int len;
    int size;
    ClearCallback ClearPtr;
};

#endif




#endif